<template>
  <el-form ref="form" :model="form" :rules="rules" label-width="120px">
    <el-form-item label="老人姓名" prop="name">
      <el-input v-model.trim="form.name" disabled placeholder="老人姓名"></el-input>
    </el-form-item>
    <el-form-item label="老人体温" prop="tiwen">
      <el-input v-model.trim="form.tiwen" disabled placeholder="老人体温">
        <el-button slot="append">℃</el-button>
      </el-input>
    </el-form-item>
    <el-form-item label="服药情况" prop="fuyao">
      <el-input v-model.trim="form.fuyao" placeholder="服药情况"></el-input>
    </el-form-item>
    <el-form-item label="饮食情况" prop="yinshi">
      <el-input v-model.trim="form.yinshi" placeholder="饮食情况"></el-input>
    </el-form-item>
    <el-form-item label="疾病情况" prop="jibin">
      <el-input v-model.trim="form.jibin" placeholder="疾病情况"></el-input>
    </el-form-item>
    <el-form-item class="contacts-add">
      <el-button type="primary" @click="onSubmit">提交</el-button>
      <el-button @click="cancle">关闭</el-button>
    </el-form-item>
  </el-form>
</template>

<script>
import * as APIDailycare from '@/api/dailycare'
import { mapState } from 'vuex'
export default {
  name: 'status-records',
  props: {
    data: {
      type: Object,
      default: () => {}
    }
  },
  computed: {
    /* ...mapState('d2admin/user', [
      'info'
    ]) */
  },
  data () {
    return {
      // 活动id
      dialogOlderVisible: false,
      form: {},
      // 表单校验
      rules: {}
    }
  },
  methods: {
    // 添加
    onSubmit () {
      this.$refs.form.validate((valid) => {
        if (valid) {
          APIDailycare.riusersEdit(this.form).then(res => {
            this.load()
            this.cancle()
          })
        }
      })
    },
    load () {
      this.$emit('load')
    },
    cancle () {
      this.$refs.form.resetFields()
      this.$emit('cancle')
    }
  },
  watch: {
    data: {
      handler (newval) {
        this.form = newval
      },
      // 可以一进页面就触发监听器  监听器自带的immediate
      immediate: true,
      deep: true
    }
  }
}
</script>

<style lang="scss">
.el-select{
  width: 100%;
}
.el-date-editor.el-input{
  width: 100%;
}
</style>
